import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDcMTbFitfOemx/8tcasryDRQk3\n' +
  'Y7Zp8szBM03xbH3s+umdI5blcUdPLs4NEH9qojFoiCb7nPg92MXEfaXy9gNZ7Qft\n' +
  'OsU5XQRhySp6e/NdbRHut1ksvJXnlUc+OLFW6RIZgHwqmsZrlWRo71MXOBoPcpss\n' +
  'VEFfqFmzDY0Nw7zUKQIDAQAB'

const privateKey = 'MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANwxNsWK1856bH/y\n' +
  '1xqyvINFCTdjtmnyzMEzTfFsfez66Z0jluVxR08uzg0Qf2qiMWiIJvuc+D3YxcR9\n' +
  'pfL2A1ntB+06xTldBGHJKnp7811tEe63WSy8leeVRz44sVbpEhmAfCqaxmuVZGjv\n' +
  'Uxc4Gg9ymyxUQV+oWbMNjQ3DvNQpAgMBAAECgYEAhU+Od58N9UaNdhGSRem81ETx\n' +
  'xYUrJY4IhVgIcoha3SU0Vxz6+MLSh5Aw1BwO6IJ2I3F7GI76hIc/hS0FUcm8UI9r\n' +
  '9QrDp9LC5lQjD8kjnLCRpKwF9fSv76asWHhKsvTDVZvsxJhuVKd6SSmFYSC5EgNx\n' +
  'uVn5PeTLCYzpNtJ6IlkCQQD9FsGOilFltYiXZWNvfdsCCBmzOQUzmoU3G/WOQHyy\n' +
  '3ue/cOYOmygDNjxm2aqBx6TAD7fs0ErnD6xnwgM6jgWnAkEA3rmXMjTgT7Ux5uE1\n' +
  'RKwUvzVPZgyNt3mvabfTU6ROFD99Rbgf7nb6Fa1+DFKXu6mxoHE6mL5c/Z8mjyru\n' +
  'fB4xrwJAFFAbQOGBHvSu/de5X11ukn8r8OKGtFmWj5HC56PtXj3dw9O/4zQ4xek4\n' +
  'd9jIgpoPcwrP7EXbfSgY4ksED1MOyQJATMjrCVIVayVquNA3jx9MX8c/Qk1dpj17\n' +
  'bhUD9DgW+wAQbjLWP14hRcv0QsdOrFIKfOfMbdBjOsTdhEomwf+e3QJBAI3y7+Z/\n' +
  '+KWOirIjXsWmGZAJSBuF4v3s5mK9lMcBBkTUggz+MwAP9gbvWkSc0jpuMGGpigKE\n' +
  'pUm/fr5oXLkGSAA='


// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

